JBoss Community Archive (Read Only)

Graphene 1

Request-Type Guards

Its purpose is to guard that the interaction of the user will raise specific request to the server. It differs between following types:

Guarding Request Type

You can create new RequestGuard with given type defined in constructor:

RequestGuard xhrGuard = new RequestGuard(RequestType.XHR);
selenium.getInterceptionProxy().registerInterceptor(xhrGuard);
selenium.click(BUTTON_START);

More intuitive and also preferred way of usage is the usage of Graphene Utility static members:

guardXhr(selenium).click(BUTTON_CAUSING_XHR);
...
guardHttp(selenium).click(BUTTON_CAUSING_HTTP);
...
selenium.click(ANY_BUTTON);

Internally, factory creates immutable copy of CommandInterceptionProxy and also AjaxSelenium and returns this modified copies, thereby the last call clicking to ANY_BUTTON will not be intercepted by any RequestGuard.

It brings simplicity to quite hard-to-understand topic.

Waiting for RequestType

Together with guarding the request type done, there is also the possibility to wait until the page will catch the given request type, ignoring all other requests.

For this purpose, you can again use Graphene Utility, similary to previous sample:

waitXhr(selenium).click(BUTTON_CAUSE_XHR);
...
waitHttp(selenium).click(BUTTON_CAUSE_HTTP);

This is useful in cases, where you expect that also other request can be done.

For example you are relocating to new URL, but on the current page is still active using AJAX (triggering XMLHttpRequest).

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-10 12:13:27 UTC, last content change 2012-03-16 14:24:21 UTC.